$(function(){

    var restore_options = function(){
        var name = $(this).attr('name');
        if (localStorage[name] !== undefined)
        {
            $(this).val(localStorage[name]);
        }
        else
        {
            localStorage[name] = $(this).val()
        }
    };

    $("input[type!=submit]").each(restore_options);
    $("select").each(restore_options);

    var save_options = function(){
        var name = $(this).attr('name');
        localStorage[name] = $(this).val();
    };

    $("#save").click(function(){
        $("input[type!=submit]").each(save_options);
        $("select").each(save_options);
        alert("Changes saved!");
    });

});